﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 日期
{
    class Program
    {
        static void Main(string[] args)
        {
            date();
            Console.ReadLine();
        }

        static void date()
        {
            int month = 0, day = 0, year = 0;

            int[] monthDay = new int[13] { 29, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

            string input;
            Console.Write("请输入\n年:");
            input = Console.ReadLine();
            year = int.Parse(input);

            Console.Write("月:");
            input = Console.ReadLine();
            month = int.Parse(input);

            Console.Write("日:");
            input = Console.ReadLine();
            day = int.Parse(input);
            Console.WriteLine("输入日期是{0}年{1}月{2}日。", year, month, day);
            //bool isRunNian = false;
            //if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
            //{
            //    isRunNian = true;
            //}
            int conditionNub = 0;

            if (month < 1 || month > 12)
            {
                Console.WriteLine("month超出范围!");
                return;
            }

            if (!(month == 2 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))))
            {
                conditionNub = month;
            }
            else
            {
                conditionNub = 0;
            }


            if (day > 0 && day <= monthDay[conditionNub])
            {
                int days = 0;
                for(int i=1;i<month;i++)
                {
                    if(i == 2 && (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)))
                    {
                        days += monthDay[0];
                        continue;
                    }
                    days += monthDay[i];
                }
                days += day;
                Console.WriteLine("输入的日期是一年里的第{0}天",days);
                if (day == monthDay[conditionNub])
                {
                    month++;
                    if (month > 12)
                    {
                        year++;
                        month = 1;
                    }
                    day = 1;
                }
                else
                {
                    day++;
                }
            }
            else
            {
                Console.WriteLine("day超出范围!");
                return;
            }

            Console.WriteLine("下一天是：{0}年{1}月{2}日", year, month, day);
        }
    }
}
